---
title: MCP Resources
description: Learn how to publish MCP resources seamlessly using GenAIScript.
keywords: MCP, GenAIScript, resources, publishing
date: 2025-03-30
cover:
  alt: A colorful 2D illustration in an 8-bit retro style, depicting a stylized
    server setup with abstract data nodes linked by lines. The design uses five
    corporate colors, forming a geometric pattern that symbolizes data and
    resource exchange. The interconnected nodes illustrate a protocol for
    interaction, creating an iconic and corporate atmosphere without any people
    or text.
  image: ./mcp-resources.png
tags:
  - MCP resources
  - Model Context Protocol
  - MCP tools
  - publishResource method
  - GenAIScript framework
excerpt: The Model Context Protocol (MCP) introduces a powerful way for scripts
  to provide context to large language models (LLMs) by exposing data through
  MCP resources. These resources enable servers to share structured content that
  clients can access and utilize efficiently. By integrating `publishResource`
  into your workflows, you can streamline how your applications interact with
  MCP clients, enhancing context discovery and resolution. Dive deeper into how
  MCP tools and resources can elevate your systems today.

---

import BlogNarration from "../../../components/BlogNarration.astro"

<BlogNarration />

# MCP Resources

In a [previous post](/genaiscript/blog/scripts-as-mcp-tools/),
we announced how every script can be a [MCP tool](https://modelcontextprotocol.io/docs/concepts/tools).

To follow up on this idea, we added support for publishing [MCP resources](https://modelcontextprotocol.io/docs/concepts/resources)
as part of the script execution.

Resources are a core primitive in the Model Context Protocol (MCP)
that allow servers to expose data and content that can be read by clients and used as context for LLM interactions.

```mermaid

graph TD
    VS[GitHub Copilot Chat] --> MCPServer[GenAIScript = MCP Server]
    MCPServer --> MCPTools1[script A = MCP Tool]
    MCPTools1 --> MCPResources1[MCP Resource]
    MCPResources1 --> MCPServer
```

MCP handles discovery and resolution of resources, so once your script publishes a resource,
the MCP client (IDE) is made "aware" of it and it can decide to read it.

## `publishResource`

The `publishResource` method allows you to publish a resource with a unique identifier and a file/string/buffer.
The rest of the MCP resource publishing process is handled by the GenAIScript framework.

```js
const uri = await host.publishResource("unique-id", file)
```

## Next steps

Are you ready to build your own MCP tools and resources?

- [Read the documentation](/genaiscript/reference/scripts/mcp-server#resources)
